﻿using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;
using System.Linq.Expressions;

namespace AVIS.OutBound.OrderPay
{

    public class OrderPayTransManager : DomainService, IOrderPayTransManager
    {

        private readonly IRepository<OrderPayTrans> _repository;

        public OrderPayTransManager(IRepository<OrderPayTrans> repository){
            _repository = repository;
        }

        public OrderPayTrans GetByAvisOBOrderId(int AvisOBOrderId)
        {
            Expression<Func<OrderPayTrans, bool>> filter = c => c.AvisOBOrderId == AvisOBOrderId;
            var entity = _repository.FirstOrDefault(filter);
            return entity;
        }

        public void Save(OrderPayTrans orderPayTrans)
        {
            if (orderPayTrans == null){
                throw new Exception("保存失败!");
            }
            orderPayTrans.CreateDate = Abp.Timing.Clock.Now;
            _repository.Insert(orderPayTrans);
        }
    }
}
